Image processing apparatus and processing method therefor

ABSTRACT

In an image processing apparatus for dividing image data into blocks having a predetermined number of pixels and processing each of the divided blocks in sequence, color data of pixels in a block to be processed is compared to identify a pattern flag that corresponds to a placement pattern of the color data included in the block. The identified pattern flag and the color data for the number of colors included in the block are output and, assuming that output color data that corresponds to a pixel at a predefined position in the block is first color data, the pattern flag, the first color data, and other color data that are output for each of the divided blocks are collectively stored in respectively different memory areas.

TECHNICAL FIELD

The present invention relates to techniques for compressing an image inpredetermined blocks and for performing image processing and restorationprocessing on an image that has been compressed on a block-by-blockbasis.

BACKGROUND ART

Conventionally, high-resolution color images are in high demand, anddigital multifunction peripherals deal with more and more images withresolutions of 1200 dpi or higher in order to meet the needs for highimage quality. Not just digital multifunction peripherals, but imageprocessing apparatuses such as digital cameras and facsimile machinesalso perform compression of color image data in order to savememory/hard disk capacity and to shorten the write time thereto, therebyachieving low cost and high speed.

Commonly used examples of color still image compression methods includeJPEG methods using discrete cosine transform and other methods usingWavelet conversion. This sort of encoding scheme typically encodes animage into predetermined blocks (e.g., in units of 8×8 or 16×16 pixels)and performs discrete cosine transform, quantization, and entropyencoding to achieve high compression efficiency. The encoding scheme ofthis kind is a variable-length encoding method, in which the amount ofencoding varies with each image to be encoded.

Because of the use of such a block-by-block variable-length encodingmethod, it is difficult to have random access to small areas forreference. Since the amount of encoding varies with each image andaccordingly a block to be decoded has an indeterminate location (memoryaddress), some means for determining the block location andblock-by-block decoding processing are necessary for random access.

The discrete cosine transform in JPEG usually necessitates 8×8 pixelsfor the block size. In order to perform discrete cosine transformprocessing on the block-by-block basis at high speed, a high-speedcomputing unit and its dedicated hardware are necessary, and a buffermemory is also necessary.

As one approach to the issues such as random accessibility and thecomplexity of processing, an image compression technique is disclosed,in which the block size is small and a fixed compression rate is used(e.g., Japanese Patent Laid-Open No. 2004-104621).

There is also another issue in that, as the resolution continues toincrease as described above, the number of pixels that require imageprocessing increases dramatically, which increases the processing load.For example, if the resolution is doubled from 600 dpi to 1200 dpi, thenumber of pixels to be processed is quadrupled. In the case of using theimage compression described above, processing for decoding compresseddata would be necessary in order to refer to such pixel data and convertit. In other words, compressed data cannot be subjected as is to imageprocessing and it always requires decoding processing, which makes itnecessary to perform pixel-by-pixel processing on all pixels inhigh-resolution data and thus causes an increase in the processing time.

Examples of disclosed techniques for performing compression processingwithout encoding pixel data include a well-known run-length compressionmethod for storing pixel data and the number of consecutive pixels, anda technique for performing compression by detecting edges in blocks andstoring two colors at the edges (e.g., Japanese Patent Laid-Open No.10-257488).

As described above, with the JPEG method using discrete cosine transformand the Wavelet conversion method, there is a problem in that a largeamount of computations and accordingly a long processing time arenecessary for each block, and also, costly processing hardware isneeded.

There is also another problem in that an enormous amount of processingtime is required depending on the number of pixels to be processed sinceimage processing performed on compressed data always requires decodingprocessing.

For example, although high-resolution data is not always necessarydepending on the application of image data, it is necessary to reducehigh-resolution data to low-resolution data in order to obtainlow-resolution data. In other words, decoding processing and separatereduction processing are always necessary in order to generatelow-resolution data from high-resolution data that has been compressedand encoded in JPEG format, for example.

SUMMARY OF INVENTION

The present invention provides an apparatus and method for performingcompression of image data while reducing the processing cost.

According to one aspect of the present invention, there is provided animage processing apparatus for dividing image data into blocks having apredetermined number of pixels and processing each of the divided blocksin sequence, the apparatus comprising: identification means forcomparing color data of pixels in a block to be processed andidentifying a pattern flag that corresponds to a placement pattern ofthe color data included in the block; output means for outputting thepattern flag identified by the identification means and the color datafor the number of colors included in the block; and storage means for,assuming that color data output from the output means that correspondsto a pixel at a predefined position in the block is first color data,collectively storing the pattern flag, the first color data, and othercolor data that are output from the output means for each of the dividedblocks in respectively different memory areas.

Further features of the present invention will become apparent from thefollowing description of exemplary embodiments with reference to theattached drawings.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram illustrating an example of the configurationof an image processing apparatus according to an embodiment.

FIG. 2 is a diagram illustrating an exemplary configuration of acontroller shown in FIG. 1.

FIG. 3 illustrates the number of all possible patterns of the fourcolors in a 2×2 pixel block.

FIG. 4 illustrates the relationship between the patterns shown in FIG. 3and a pattern flag.

FIG. 5 is a flowchart showing processing for identifying a differentnumber of pixels and a pattern flag.

FIG. 6 is a diagram for illustrating processing for determining thepositions of pixels having different pixel values.

FIG. 7 is a diagram showing an example of image data writing to memoryspace by a DMAC.

FIG. 8 is a flowchart showing compression processing according to asecond embodiment.

FIG. 9 is a diagram showing the relationship between input and output inthe case of adding a new pattern flag.

FIG. 10 is a flowchart showing compression processing according to afourth embodiment.

FIG. 11 is a diagram showing an example where image data is written tothe memory area according to the fourth embodiment.

FIG. 12 is a flowchart showing compression processing according to afifth embodiment.

FIG. 13 is a diagram showing the relationship of a page, 32×32 pixeltiles, and 2×2 pixel blocks.

FIG. 14 is a diagram illustrating a data structure of packed data.

FIG. 15 is a diagram showing an example of the structure of a packetmanagement table.

FIG. 16 is a diagram illustrating the addresses of packets written tothe memory area.

DESCRIPTION OF EMBODIMENTS

Embodiments of the present invention will now be described in detailwith reference to the accompanying drawings. In the embodiments of theinvention, the description of an image processing apparatus takes theexample of a digital multifunction peripheral (MFP) having multiplefunctions such as scanning, printing, and copying.

First Embodiment

As shown in FIG. 1, a controller 101 is connected to a scanner 102 asimage input equipment and a printer 103 as image output equipment. Thecontroller 101 is also connected to a network 104 such as a LAN or apublic network (WAN) to input and output image and device informationand to perform image decompression of PDL data.

A CPU 105 is a processor that controls the overall MFP in accordancewith computer programs stored in an HDD storage unit 107, which will bedescribed later. A memory 106 is a system work memory for the CPU 105 tooperate and is also an image memory for temporarily storing image data.The HDD storage unit 107 is a hard disk drive (HDD) that stores systemsoftware, computer programs, image data, and so on.

Next is a detailed procedure of processing performed by each unit of thecontroller 101 with reference to an exemplary configuration of thecontroller 101 shown in FIG. 2. First is a description of the case ofreading image data scanned by the scanner 102. A scanner imageprocessing unit 201 receives an input of three-color, that is, RGB (red,green, and blue), image data scanned by the scanner 102 and performsimage processing such as shading and filtering on the image data, andthen a compression unit 202 performs image compression processing. Then,a direct memory access controller (DMAC) 203 stores the compressed datain the memory 106 via an image memory bus.

Next, in the case of printing scanned image data, a DMAC 211 transferscompressed data stored in the memory 106 to a color processing unit 212via the image memory bus. Then, a color processing unit 212 converts itinto CMYK (cyan, magenta, yellow, and black) color space. Thereafter,the color processing unit 212 further performs color processing such asdensity control and printer gamma correction on each of the CMYK values,and then the DMAC 211 stores the color-processed data again in thememory 106 via the image memory bus. After that, for execution of printimage processing, a DMAC 221 reads the compressed data stored in thememory 106 via the image memory bus and a decompression unit 222decompresses the data into raster image data. Then, a print imageprocessing unit 223 receives an input of the CMYK raster image data,performs area converge modulation by means of dithering or errordiffusion, and outputs it to the printer 103.

Moreover, in the case of transmitting scanned image data to the network,the DMAC 211 transfers compressed data stored in the memory 106 to thecolor processing unit 212 via the image memory bus. Then, the colorprocessing unit 212 performs processing such as display gamma adjustmentor paper ground color adjustment and then converts it into YCbCr(luminance, blue chrominance, and red chrominance) color space. Then,the DMAC 211 again stores the data processed by the color processingunit 212 in the memory 106 via the image memory bus. Thereafter, forexecution of transmission image processing, a DMAC 231 transfers thecompressed data stored in the memory 106 to a decompression unit 232 viathe image memory bus. Then, the decompression unit 232 decompresses thecompressed data into raster image data. After that, a transmissionprocessing unit 233 performs either JPEG compression processing on theYCbCr raster image data for color image transmission or binarization andJBIG compression, for example, on the Y data for monochrome binary imagetransmission, and outputs the compressed data to the network 104.

Furthermore, in the case of storing scanned image data, a DMAC 241transfers compressed data stored in the memory 106 to a disk spoolhigh-compression/decompression unit 242 via the image memory bus. Thedisk spool high-compression/decompression unit 242 further performshigh-compression JPEG compression since the write speed to the HDD isslower than that to the memory. Thereafter, the compressed data isstored in the HDD storage unit 107 via a disk access controller 243. Inthe case of transferring compressed data stored in the HDD storage unit107 again to the memory 106, it is sufficient to perform the reverse ofthe above-described processing.

The following is a description of the case where PDL data that has beentransmitted from another apparatus connected via the network 104 shownin FIG. 1 is written to the memory 106. Although a PDL interpretationunit is not shown in FIG. 2, the CPU 105 serving as a PDL interpretationunit interprets PDL data and outputs a display list as a result to thememory 106. Thereafter, a rendering unit 251 renders the display liststored in the memory 106 in RGB raster image data, and the compressionunit 252 performs image compression processing. Then, the DMAC 253stores the compressed data in the memory 106 via the image memory bus.

Note that processing for printing PDL data, transmitting it to thenetwork, or storing it can be achieved by performing similar processingto that in the case of scanned image data.

Next is a detailed description of compression processing performed onraster image data, which is one of the features of the presentinvention. Note that although the compression unit 252 compresses araster image generated from PDL data and the compression unit 202compresses a raster image obtained by scanning in the presentembodiment, the present invention is not intended to be limited to sucha configuration. For example, the configuration may also be such that acommon compression unit is provided, instead of providing thecompression units 202 and 252 separately as shown in FIG. 2.

In the present embodiment, first, raster image data in pages is dividedinto 2×2 pixel blocks, and data compression processing is performed oneach of the divided and extracted blocks.

Before giving a description of the compression processing, consider thenumber of possible color combinations in accordance with the number ofcolors contained in 2×2, that is, 4 pixel data. Since the number ofpixels is four, the number of colors contained in those pixels is fourat maximum, so only one to four combinations exist in a block. FIG. 3illustrates the number of all possible patterns of the four colors.

First, in the case where a block contains a single color, it means thatall four pixels are of the same color and thus there is only a singlepattern. Next, consider the case where two colors exist in a block. Asshown in FIG. 3, in the case where two colors are laid out in fourpixels and assuming that the color of the upper left pixel is referredto as a first color and the other color is referred to as a secondcolor, the remaining three pixels except the upper left pixel will haveeither the first or second color, from which it is evident that sevenpossible patterns in all are considered, except for the case where allfour pixels are of the same color.

Then, consider the case where a block contains three colors. The numberof occurrences that three colors are laid out within four pixels can berephrased as the number of occurrences that only one of the three colorsis used twice, so it is sufficient to obtain the number of occurrencesthat two pixels are the same color out of the four pixel coordinates.That is, the number of possible patterns of the three colors is six inall since it is equivalent to the number of combinations taking two outof the four coordinates. Finally, in the case where a block containsfour colors, there is only a single pattern as in the case of a singlecolor.

By totaling the numbers of all possible patterns of one to four colors,15 patterns in all are considered. Also, if it is considered that a flag(identifier) is assigned in order to identify all those patterns,another 4 bits are necessary for the amount of flag data. Therelationship between the 15 patterns and the flag is defined as shown inFIG. 4, and this flag is hereinafter referred to as a “pattern flag”.

As described above, in view of all possible patterns with 2×2 pixels,processing performed by the compression units 202 and 252 will bedescribed with reference to FIG. 5. The description is given for examplewith the assumption that RGB have 8 bits or 256 levels each as input andsuch 8-bit data is dot-sequentially arranged, forming an image of 24bits per pixel as data.

First, a 2×2 pixel block is input (S501) and all pairs of pixels in thatblock are compared with respect to their 24 bits (S502). As the resultof the comparison, if all bits match, 1 is output, and if not, 0 isoutput.

Herein, 2×2 pixels have coordinates 1, 2, 3, and 4 in order of upperleft, upper right, lower left, and lower right, respectively (asindicated by 401 in FIG. 4). Since the number of possible combinationsof the two pixel coordinates is six in all, namely 1-2, 1-3, 1-4, 2-3,2-4, and 3-4, (as indicated by 402 in FIG. 4), the comparison needs tobe performed six times and accordingly six bits are output as a result.As shown by the comparison results in FIG. 4, if all pixels are of thesame color, all comparison results are the output of 1, whereas if allfour pixels have different pixel values, all comparison results are theoutput of 0.

In the present example, since the number of possible patterns that canoccur by color matching of four pixels is 15, a 4-bit pattern flag isidentified according to the 6-bit comparison result as shown in FIG. 4(S503). Next, the number of colors found in four pixels and color dataare extracted (S504). As shown in FIG. 4, since each patternrepresenting the location(s) of color(s) in a block is associated withthe 4-bit pattern flag (or 6-bit comparison result), it is possible toidentify the number of colors in each block and color data. Note that,in the present embodiment shown in FIG. 4, it is defined in all patternsthat the color (pixel value) of the upper left pixel is a first color(first color data). In the case where the pattern flag is 0, the numberof colors is one, so that the color (pixel value) of the upper leftpixel is extracted as the first color. In the case where the patternflag is any of 1 to 7, the number of colors is two, so that the color(pixel value) of the upper left pixel is extracted as the first colorand further the color (pixel value) of a pixel at the position definedby the pattern flag where the second color (second color data) exists isextracted. For example, when the pattern flag is 1, the color of theupper right pixel is extracted as the second color. In the cases wherethe pattern flag is any of 8 to D, the number of colors is three, sothat the color (pixel value) of the upper left pixel is extracted as thefirst color and further, the colors (pixel values) of pixels at thepositions defined by the pattern flag where the second color (secondcolor data) and the third color (third color data) exist are extracted.For example, when the pattern flag is 8, the color (pixel value) of theupper right pixel is extracted as the second color and the color (pixelvalue) of the lower right pixel is extracted as the third color. In thecase where the pattern flag is E, the color of the upper left pixel isextracted as the first color, the color of the upper right pixel isextracted as the second color, the color of the lower left pixel isextracted as the third color, and the color of the lower right pixel isextracted as the fourth color.

That is, based on the pattern flag (or the comparison result), thenumber of colors in a block is identified (S505, 5507, and S509) and thepattern flag and color data corresponding to each block are output(S506, 5508, 5510, and S511). This output data is described withreference to FIG. 6.

As shown in FIG. 6, for example in the case where the pattern flag is 0(i.e., four pixels are of a single color) (YES in S505), the 4-bitpattern flag and the pixel value for the first color (24-bit color data)are output since the second and other colors do not exist (S506). In thecases where the pattern flag is any of 1 to 7 (i.e., four pixels are oftwo colors) (YES in S507), the coordinates of the pixel where the secondcolor exists is calculated using the pattern flag, and the 4-bit patternflag and the pixel values for the two colors (48-bit color data) areoutput (S508). In the cases where the pattern flag is any of 8 to D(i.e., three colors) (YES in S509), the 4-bit pattern flag and the pixelvalues for three colors (72-bit color data) are output (S510). In thecase where the pattern flag is E (i.e., four colors) (NO in S509), the4-bit pattern flag and the pixel values for four colors (96-bit colordata) are output (S511). In other words, outputting color data from eachblock is equivalent to outputting color data that has not appeared, insequence from the first color when scanning is performed in order of thecoordinates in a block (from 1 to 4 in order of upper left, upper right,lower left, and lower right).

In this way, outputting the 4-bit pattern flag and the pixel values forthe number of colors existing therein for four-color input data (96bits) in a 2×2 pixel block enables a reduction in the amount of outputdata with relatively simple processing. In particular for a raster imagethat contains many 2×2 pixel blocks where pixels are of the same color(i.e., blocks with a small number of colors), the amount of output datawill have a high compression rate. It is also possible to identify thenumber of colors in a block by referring to the pattern flag. Performingsuch processing on all image blocks enables compression of the overallimage data.

Next, the DMAC (203, 253) performs processing for writing the patternflag and color data obtained as described above to the memory (memorystorage processing). Here, the DMAC writes the pattern flag, the firstcolor data, and the second, third, and fourth color data in differentlocations. Three addresses are specified to the DMAC, namely, a memorystarting address to write the pattern flag, a memory starting address towrite the first color data, and a memory starting address to write thesecond color data onward. In other words, the pattern flags of everyblock are stored collectively in a pattern-flag storage section of thememory (a memory area for storing the pattern flag). The first colordata of every block is stored collectively in a first-color storagesection of the memory (a memory area for storing the first color data ofevery block). Moreover, the second, third, and fourth color data ofevery block is stored collectively in a second-, third-, andfourth-color storage section of the memory (a memory area for storingthe second, third, and fourth color data of every block).

FIG. 7 is a diagram showing an example of image data being written tomemory space by the DMAC. Note that, when an M×N pixel image with RGBcolors having 8 bits each is input into the compression unit, the datasize of the pattern-flag storage section where pattern flag data isstored is (M×N×4/8) bytes. The data size of the first-color storagesection where the first color data is stored is (M×N×24/8) bytes. Thedata size of the second, third, and fourth-color storage section wherethe second, third, and fourth color data is stored varies with eachraster image to be processed. This is because the number of blocks wherethe second, third, and/or fourth colors exist varies with each image.

Here, as to the memory area after the first-color write starting address(the first-color storage section and the second-, third-, andfourth-color storage section), color data of each pixel is stored as iswithout changing the number of bits. That is, unlike compressed datasuch as in JPEG format, the color (pixel value) of each pixel can beidentified without decoding compressed data into a raster image.Accordingly, in the case of performing color processing that iscompleted with one pixel input and one pixel output, such as colorconversion and gamma correction processing using an LUT or color spaceconversion processing using matrix operations, it is possible to performthe processing directly on the data stored as shown in FIG. 7 withoutneeding to return it to an original raster image. When the colorprocessing unit 212 shown in FIG. 2 performs image processing on apixel-by-pixel basis, pixel data after the first-color write startingaddress in the memory 106 is read via the DMAC 211, processed on apixel-by-pixel basis, and then written back to the memory 106. Here, ifsome sort of pixel-by-pixel processing does not cause any change in thenumber of bits per pixel, data may be overwritten in the same place,which allows the space of the memory 106 to be saved.

Direct use of compressed data like this enables improvement in thetransfer efficiency of the memory bus and increasing the processingspeed since color data to be processed is less than the number of pixelsin an original raster image.

Moreover, image data is divided into the pattern flag, the first color,and the other colors and stored discretely in the memory as shown inFIG. 7. Thus, the first-color storage section of the memoryconsecutively stores pixel values (color data) that are obtained bydividing a raster image into 2×2 pixel blocks and sampling the pixel atthe upper left coordinates in each block.

The MFP also has functions such as previewing accumulated PDL image dataor scanned image data and making network transmissions as describedabove. For example, even though the print resolution is 600 dpi, such ahigh resolution is often not required for preview or transmission, atwhich time a resolution of 300 dpi or lower would be enough. In caseswhere reduced data needs to be obtained like this, a half-sized rasterimage can be obtained in a simple way by collectively extracting onlythe first color data stored in the first-color storage section.

The following is a description of size reduction and transmission, forexample in a case where a 600 dpi raster image has been converted intoand accumulated as data as shown in FIG. 7. If 300 dpi is specified asthe resolution of an image to be transmitted, it is sufficient toextract and transmit the data stored in the first-color storage sectionas it is. If the resolution specified is higher, such as 400 dpi, thanthe sampling resolution of 300 dpi in the first-color storage section,the following processing is performed. Specifically, compressed data isdecompressed based on the data stored in the pattern-flag storagesection, the first-color storage section, and the second-, third-, andfourth-color storage section, then the decompressed data is scaled usingknown scaling processing, and the scaled image is transmitted. If atransmission resolution lower than 300 dpi is specified, only the datastored in the first-color storage section is used to perform scalingprocessing to obtain the specified resolution. In this way, it issufficient to read data while switching it in accordance with thedesired image size.

Next is a description of the decompression units 222 and 232 paired withthe compression units 202 and 252. Note that the decompression units 222and 232 perform processing for restoring the pattern flag and color dataas described above into raster image data. Three addresses are specifiedto the DMACs 221 and 231, namely, the pattern-flag write storageaddress, the first-color write starting address, and the second-,third-, and fourth-color write starting address for compressed data laidout in the memory 106 as shown in FIG. 7. The DMACs 221 and 231 readdata from the three addresses and transfers it to the decompressionunits 222 and 232.

The decompression units 222 and 232 first interpret the 4-bit patternflag and calculate the number of colors in that block. In addition tothe first color data, they also read the second, third, and/or fourthcolor data in accordance with the number of colors and relocate thefirst color and the second, third, and fourth color data in accordancewith a color data placement pattern (FIG. 4) that has been predefinedfor each pattern flag. In this way, each 2×2 pixel block is decompressedand decoded.

In a case where the decompression units 222 and 232 reduce the imagesize to half, only the first-color write starting address is specifiedto the DMACs 221 and 231 since the pattern flag and the second, third,and fourth color data are unnecessary as described above. Thereby, onlythe first color data is read from the memory 106 to constitute an image.Such processing enables a savings in the bandwidth of the memory bus.

The first embodiment enables not only a savings in the memory capacityand the bandwidth of the memory bus with a relatively simple compressionmethod, but also reducing processing loads at the time of pixel-by-pixelimage processing or size reduction and scaling processing.

Note that although the patterns indicating the locations of color dataand the pattern flag are associated as shown in FIG. 4 in the firstembodiment, the present invention is not intended to be limited thereto.For example, the association between the patterns indicating thelocations of color data and the pattern flag may be associated andpredefined such that the pixel value of the lower right pixel in each2×2 pixel block is the first color. Also, although the description ofthe first embodiment has been given with the assumption that the blocksize is 2×2 pixels, the present invention is not intended to be limitedthereto. Moreover, although the description of the compression has takenthe example of image data with RGB having 8 bits each, image data may bein CMYK color space, or it may be gray-scale data, or it may have apixel value other than 8 bits.

Second Embodiment

Next is a detailed description of a second embodiment according to thepresent invention with reference to the drawings. In the secondembodiment, a description is given of processing for compressing scannedimage data. Note that the description of the second embodiment alsotakes the example of an MFP as an image processing apparatus as in thefirst embodiment.

Images that are expected to be highly compressed by the compressionmethod of the first embodiment are those that contain many areas inwhich adjacent pixel values do not have even a single level ofdifference therebetween. Specifically, raster image data rendered ashigh-resolution PDL data (e.g., a document image generated byword-processing software) would likely have a high compression rate. Onthe other hand, scanned input images would likely have noise componentsof a scanner superimposed thereon and thus can contain many areas inwhich adjacent pixel values have several levels of differencetherebetween.

In such cases, 2×2 pixel blocks of compressed data are more oftendetermined to be of four colors, which not only results in no reductionin the amount of data after compression but also makes it more likelythat the amount of data will be increased by the addition of the patternflag. However, in some images, several levels of difference in a 2×2pixel block cannot often be recognized visually, in which case it can besaid that such several levels of difference are redundancy data.

Thus, a description is given in the second embodiment of a method thatenables high compression of scanned image data as well. As describedabove, if pixels in a block have only several levels of differencestherebetween, they are considered as the same color and color-reductionprocessing is performed on each block, which enables a reduction in thenumber of blocks that are determined to be of four colors and animprovement in the compression rate.

After the color-reduction processing is performed on each block, imagecompression processing is performed based on all possible patterns with2×2 pixels as shown in FIG. 4 of the first embodiment, which will now bedescribed with reference to FIG. 8. As in the first embodiment, thedescription is given of the case where the RGB colors have 8 bits or 256levels each as input.

First, a 2×2 pixel block to be processed is input (S801) andcolor-reduction processing is performed, in which a single color isobtained from the four pixel values (S802). Here, such color-reductionprocessing to obtain a single color can be achieved by calculating anaverage pixel value of the four pixels, for example. Specifically,differences between the pixel value obtained by color-reductionprocessing and the input four pixel values are calculated (S803) and themagnitude of the differences is determined (S804). For example, the sumof the absolute values of the differences between the input pixel valuesand the RGB values after the color-reduction processing is obtained, andif the sum is not more than a threshold value, the differences can bedetermined to be small. Specifically, if the differences are determinedto be small, it is determined that the number of colors can be reducedto one, so the pattern flag is identified as 0 (S805) and a single pixelvalue obtained by the color-reduction processing and the pattern flagare output (S806).

If the differences are determined to be large, then othercolor-reduction processing is performed to obtain two colors (S807).Here, the number of colors can be reduced to two, for example, byextracting two pixels A and B whose differences in RGB values are thelargest among the four pixels, then clustering the remaining two pixelsinto either of the two pixels A and B depending on to which it is moresimilar, and then obtaining an average value in each of the clusters.Then, differences between the two color pixel values and the input fourpixel values are calculated (S808) and the magnitude of the differencesis determined (S809). Here, if the differences are determined to besmall, the pattern flag is identified in accordance with the positionsof the pixel values after the number of colors is reduced to two, basedon the correspondences as shown in FIG. 4 in the same manner asdescribed in the first embodiment (S810). Then, the two color pixelvalues obtained by the color-reduction processing and the pattern flagare output (S811).

Here again, if the differences are determined to be large, then othercolor-reduction processing is performed to obtain three colors (S812).Here, the number of colors can be reduced to three, for example, byextracting two pixels whose differences in RGB values are the smallestamong the four pixels, then obtaining an average value of the two pixelvalues, and adding the average pixel value to the other two pixel valuesto have three colors. Then, differences between the three color pixelvalues and the input four pixel values are calculated (S813) and themagnitude of the differences is determined (S814). If the differencesare determined to be small, the pattern flag is identified in accordancewith the positions of the pixel values after the number of colors isreduced to three, based on the correspondences as shown in FIG. 4 in thesame manner as described in the first embodiment (S815). Then, the threecolor pixel values obtained by the color-reduction processing and thepattern flag are output (S816).

Here again, if the differences are determined to be large, it isdetermined that performing color-reduction processing on that block cancause visual problems, so the pattern flag is identified as E (S817) andall four pixel values and the pattern flag are output (S818).

The pattern flag and the pixel values (color data) output in this wayare stored separately in the area for storing the pattern flag, the areafor storing the first color data, and the area for storing the second,third, and fourth color data other than the first color data, as shownin FIG. 7.

According to the second embodiment, treating similar colors as the samecolor enables improvement of the compression rate of such images astypified by scanned images whose compression rate can be degradeddramatically due to several levels of difference between pixel values.It is also possible, by appropriately setting the threshold value usedfor the aforementioned determination of differences, to control thecompression rate and image quality. For example, if no tolerance isallowed (i.e., the threshold value is set to 0), completely losslessimage compression is performed. On the other hand, if an infinite valueis set as the tolerance, each block will be represented by a singlecolor, which is equivalent to reducing the resolution to half and thusassures that the amount of data can be reduced to one fourth. Byproviding a user interface for setting such a threshold value, each usercan set the desired image quality and compression rate.

Although the compression method using color-reduction processing hasbeen described in the second embodiment, it is not necessary whenperforming decompression processing to take into consideration whetheror not the compression method has been accompanied with color-reductionprocessing, so completely the same configuration as used in the firstembodiment can be used.

Moreover, the compression method using color-reduction processingdescribed in the second embodiment is merely one example, and can alsobe implemented by using any other known color-reduction processing. Forexample, another known technique for obtaining color differences may beused instead.

Third Embodiment

Next is a detailed description of a third embodiment according to thepresent invention with reference to the drawings. In the thirdembodiment, a description is given of the case where attribute dataassociated with each pixel is compressed, in addition to raster imagedata compressed as described in the first and second embodiments. Notethat the description of the third embodiment also takes the example ofan MFP as an image processing apparatus as in the first and secondembodiments.

In a raster image generated by rendering PDL data, an attribute can beadded to each pixel. Examples of the attribute include character,photograph, graphics, background, and gray compensation. For images withsuch attributes, image processing appropriate for each attribute isperformed while switching the contents of the processing, which allowsoptimal images to be obtained. For example, it is conceivable thatprocessing for improving contrast for higher readability may beperformed on pixels having a character attribute, and processing forenriching tone may be performed on pixels having a photograph attribute.

An image associated with such attribute information is generated by therendering unit 251 shown in FIG. 2, and data of the image is stored inthe memory 106 via the compression unit 252 and the DMAC 253 asdescribed above.

When reading an image including attribute data from the memory 106 viathe DMAC 211, the color processing unit 212 performs conversionprocessing of pixel values while switching image processing depending onthe attribute data.

Thus, in the third embodiment, a description is given of a method forenabling excellent compression of image data including attribute datawith the compression methods described in the first and secondembodiments. Note that a description is given of image compressionprocessing performed based on all possible patterns with 2×2 pixels asin the first and second embodiments. Basically, an approximate procedureis identical to those described in the first and second embodiments andthus described with reference to the same drawings. It is assumed thatinput contains 8-bit attribute data per pixel, in addition to RGB colorshaving 8 bits or 256 levels each. Here, it is assumed that the 8-bitattribute data is stored as an index value such as a value A forcharacters and a value B for photographs. Also, the attribute data mayhave multiple meanings and thus the attribute can mean both characterand gray compensation, for example.

With a compression method that does not allow even a single level ofdifference as in the first embodiment, attribute data and pixel valuedata are treated in the same way and it is sufficient to expand the24-bit comparison of the RGB to 32-bit comparison of both the RGB andthe attribute. However, in the case of compression using color-reductionprocessing, such simple expansion will cause problems since attributedata is an index value.

In the aforementioned embodiments, 24 bits of the pixel values of pixelsare compared to determine if they are of the same color, and differencesof those 24 bits are calculated and treated as differences betweenpixels. In other words, the definition of the same color is such thatthe pixel values are the same or, in the case of color-reductionprocessing, they are similar enough to be regarded as the same. If thepixel value is simply increased by 8 bits of attribute data and treatedas a 32-bit pixel value, the same color has different meanings. This isbecause, since the value of attribute data means an index, thedetermination of whether it is similar or dissimilar cannot be made byonly the difference in value. Accordingly, when attribute information isadded to the pixel value, it is necessary to change the method ofcolor-reduction processing or difference calculation from the methodusing only pixel values.

A description is given of color-reduction processing in theaforementioned compression processing, with the addition of attributedata. Since the attribute data has meaning in the index as describedabove, it is unable to simply obtain an average value or the like. Thus,for example, priorities, such as the character attribute deservinghigher priority than the background attribute, are assigned to theattribute, and in the case where an average of n pixels is obtained, theattributes of those pixels are replaced with the highest-priorityattribute among them. With such a method, the aforementionedcolor-reduction processing is performed on 24 bits of the pixel valuerepresenting the color tone, whereas priority considered replacementsare performed for color-reduction processing of the attribute data. Thisenables color-reduction processing of pixel data including attributedata.

Next is a description of the difference calculation processing in theaforementioned compression processing. In the difference calculation,the sum of the absolute values of the differences for 24 bit pixelvalues is obtained, and the difference between attribute data is addedto this after having performed some sort of evaluation in which a scaleis applied to the absolute values of the differences of the pixelvalues. For example, if the attribute of pixel values change fromphotograph to character, the amount of that change is consideredequivalent to 30 levels of change in pixel values, so it is added to thesum of the absolute values and compared with a threshold value.

Such a difference in attribute data is difficult to calculate and thusmay be stored in a table. With such a table, for example in a case wherethe attribute of even a single pixel is not allowed to change, maximumvalues can be set to all values in the table so that color-reductionprocessing that can cause a change in attribute will not be performed.In contrast, in a case where pixels having the same pixel values need tobe regarded as the same color even though they have differentattributes, 0 can be set to all values in the table so that anydifference in attribute will be treated as 0 irrespective of any changein attribute and whether or not to perform color-reduction processingwill depend only on differences between pixel values.

According to the third embodiment, compression processing can beperformed even in the case of handling image data with attribute dataassigned to each pixel. Although the compression of attribute datadescribed herein focuses on PDL images, similar compression processingcan also be performed on scanned images with attribute data assigned byimage recognition. Moreover, attribute data is not intended to belimited to 8 bits per pixel and may contain any number of bits, such asa single bit, four bits, or 16 bits.

Fourth Embodiment

Next is a detailed description of a fourth embodiment according to thepresent invention with reference to the drawings. In the fourthembodiment, a description is given of other processing for compressingthe raster image data described in the first and second embodiments.Note that the description of the fourth embodiment also takes theexample of an MFP as an image processing apparatus as in the firstembodiment.

Images that are expected to be highly compressed by the compressionmethods of the aforementioned embodiments are those that contain manyareas in which adjacent pixel values either represent the same color ordiffer only by levels small enough to be regarded as the same byexecution of color-reduction processing. Focusing on such image areas,pixel values not only within a 2×2 pixel block but also those in areasincluding adjacent 2×2 pixel blocks often represent the same color ordiffer only by levels small enough to be regarded as the same color.

Thus, in the fourth embodiment, a description is given of a compressionmethod that focuses on the similarity of adjacent blocks, in addition tothe compression methods that focus on only compression within blocks,which have been described in the foregoing embodiments. In FIG. 4, 15possible pattern flags for a 2×2 pixel block are represented by 4 bits.Since 4 bits allow representation of 16 patterns, there still remainsspace for description of one more pattern, that is, the pattern flag hasredundancy.

Thus, the pixel values of the previous block of a currently processedblock are stored in that space, and if it can be determined that allpixels match those of the current block (or are similar enough afterexecution of color-reduction processing), a flag indicating that thecurrent block is the same as the previous one is set without outputtingthe pixel values (color data) of the current block. By allocating thispattern flag to the remaining 4-bit pattern, data can further becompressed without changing the number of bits of the pattern flagdescribed in the aforementioned embodiments.

FIG. 9 is a diagram illustrating the number of bits in the case wherethe flag (hereinafter referred to as a “repeat flag”) indicating thatthe current block has the same pattern as the previous block is added asa new pattern flag. In the present example, the pattern flag “F” isadded to represent matching with the previous block (i.e., new pixelvalues are not output). As shown in FIG. 9, a block having the patternflag F can be represented by the 4-bit pattern flag. In other words, ablock with the pattern flag F can be decompressed by referring to thepixel values (color data) of the previous block and the pattern flag,which eliminates the need to store the pixel values (color data) andimproves the compression rate.

The following is a detailed description of the compression processingaccording to the fourth embodiment with reference to FIG. 10. First,raster image data is input (S1001) and a 2×2 pixel block is extractedtherefrom (S1002). Next, if the extracted block is an initial block (YESin S1003), then compression processing is performed in the same manneras described in the above embodiments since no prior block exists(S1007). On the other hand, if the extracted block is determined as notbeing the initial block in S1003, differences from the previouslyprocessed and stored block are calculated (S1004). This processing canbe performed, for example, by obtaining the sum of the absolute valuesof the differences between pixel values at the same coordinatepositions. Here, if the difference is smaller than a threshold value, itis determined that the same data as the previous block that was laststored can be used (YES in S1005). Then, the pattern flag is identifiedas “F” indicating that the current block is the same as the previousblock (S1006), so the output of the pixel values (color data) isomitted. In other words, if the difference between the block to beprocessed and the previous block to be processed is determined to besmall, the pattern flag F (repeat flag) indicating a repetition of theprevious block is output for the block to be processed.

If the difference is not smaller than the threshold value in S1005, itis determined that the data of the previous block cannot be reusedbecause of a large difference from the previous block, and normalcompression processing is performed as described in the aboveembodiments (S1007). Thereafter, the data is decompressed (S1008) andthe decompressed 2×2 pixel block is stored as updated “previous blockdata” (S1009). Although the previous block data is updated in S1008 andS1009 after execution of the compression processing in S1007 in thepresent embodiment, the present invention is not intended to be limitedthereto. For example, the previous block data may be updated using thepixel values of the block to be processed, prior to execution of thecompression processing in S1007.

Next, the pattern flag and the color data obtained as a result of normalcompression processing in S1007 are output for a block whose differencefrom the stored block is not smaller than the threshold value, whereasonly the pattern flag F is output for a block whose difference is small(S1010). By repeating this processing until the last block (YES inS1011), the compression processing of the whole image is completed.

Although the compression rate can reliably be improved as compared withthe case of the aforementioned embodiments since the number of bits ofthe pattern flag is not increased and remains the same, that is, 4 bits,the first color data has an indeterminate image size (varies withimages) like the second, third, and fourth color data.

Accordingly, as shown in FIG. 11, the first color data and the second,third, and fourth color data cannot be stored in consecutive memoryspace, and it is necessary to discretely store the first color data andthe second, third, and fourth color data. In the previous description,the color processing unit 212 shown in FIG. 2 can read pixel data afterthe first-color write starting address in the memory 106 via the DMAC211 and can write it back to the memory 106 after completion ofpixel-by-pixel processing. However, in the fourth embodiment, it isnecessary to specify the second, third, and fourth-color write startingaddress, in addition to the first color address, to the DMAC 211 of thecolor processing unit 212 since the first color data and the second,third, and fourth color data are not stored in consecutive memory space.

In the present example, although the previous left block is defined asthe previous block and the state of matching or mismatching with thatblock is stored, the present invention is not intended to be limitedthereto. For example, matching with a broader area can be defined byusing upper blocks for matching or expanding the number of bits of thepattern flag.

Next is a description of decompression processing paired with thecompression processing. The decompression processing is processing forrestoring the pattern flag and the pixel data, described above, intoraster image data. The three addresses of compressed data located in thememory 106 as shown in FIG. 11, namely the pattern-flag write startingaddress, the first-color write starting address, and the second, third,and fourth-color write starting address, are specified to the DMACs 221and 231. If a block of interest is identified as the same as theprevious block by referring to the pattern flag, the output of theprevious block is used as is as the output of the block of interest, andif the pattern flag is other than that, decompression will be performedin the same manner as described above. This time, a single block of dataneeds to be buffered because it may be used for the next block.

However, in the case of reducing the image size to half throughdecompression processing, data that matches an adjacent block cannot bedecompressed by reading only the first color data from the memory 106and forming an image as described above. Thus, in the decompressionprocessing according to the fourth embodiment, the pattern flag isreferred to restore a half size image based on the first color data. Inthis case, it is not necessary to use the second, third, and fourthcolor data. More specifically, if a block of interest is identified asthe same as the previous block by referring to the pattern flag, theprevious color data in the first color data is repeatedly output, whichenables decompression. This enables a savings in bandwidth of the memorybus.

According to the fourth embodiment, focusing on similarity betweenadjacent blocks enables a reduction of redundancy between blocks andimproving the compression rate, which can achieve similar effects tothose observed in the case of implementing the color processing asdescribed in the above embodiments that can be completed by one pixelinput and one pixel output.

Fifth Embodiment

Next is a detailed description of a fifth embodiment according to thepresent invention with reference to the drawings. The fifth embodimentenhances random accessibility in the compression processing of rasterimage data in the aforementioned embodiments. Note that the descriptionof the fifth embodiment also takes the example of an MFP as an imageprocessing apparatus as in the first embodiment.

As described previously, the compression processing is variable-lengthcompression processing that depends on image data and has variable sizefor compressed data. The compressed data has thus no randomaccessibility and is not fit for the purpose of extracting andprocessing part of an image, for example.

The following is a detailed description of a compression method thatfocuses on improving random accessibility as compared to the methodsdescribed in the foregoing embodiments, with reference to FIG. 12.First, raster image data is input in pages shown in FIG. 13 (S1201).Then, a single page background pixel is set for each page of the imagedata (S1202). This is pixel data to be used as an initial storage blockat the time of compression processing and it is usually white (255 inthe case of an image with the RGB colors having 8 bits each, or 0 in thecase of a CMYK image). Next, image data as an input of the compressionunit is divided into a predetermined size of blocks (S1203). The blocksize in the fifth embodiment is 32×32 pixels. In the followingdescription, these blocks are referred to as “tiles” so as to bedistinguished from the 2×2 pixel blocks described above. A single tilecontains 16×16 blocks each being a 2×2 pixel block. FIG. 13 is a diagramillustrating the relationship of a page, 32×32 pixel tiles, and 2×2pixel blocks.

Next, header information with a predetermined fixed length is assignedto each tile (S1204). This header information includes a page ID, tilecoordinates, color space, the number of bits in pixel data, the datasize of the tile, the presence or absence of attribute information, anda compression flag, for example. Here, the page ID is a unique ID numberassigned to each page. The tile coordinates are coordinate informationindicating the location of the tile in the raster image in pages. Here,the coordinates are described in two dimensions, namely X and Ycoordinates. The color space is information indicating an identifier foridentifying whether the tile is an RGB image, a CMYK image, or agray-scale image. The number of bits in pixel data is informationindicating the bit length per pixel in the tile. The data size isinformation in bytes, indicating the size of the first color data andthe size of the second, third, and fourth color data in the tile. Thepresence or absence of attribute information is information indicatingwhether or not attribute information such as character or photograph isassigned to each pixel in image data. The compression flag is flaginformation indicating whether the tile is compressed or uncompresseddata. Note that this compression flag will be described later in moredetail.

Next, compression processing is applied to the above-described tiles(S1205). This compression processing is similar to that described in theabove embodiments and thus has not been described here. Note that aninitial storage block is defined as a storage block at the time ofcompressing the first 2×2 pixel block, for which a block filled withbackground pixels is used. This may eliminate the need to output pixeldata of the first 2×2 pixel block in each tile and accordingly canreduce the amount of data for those blocks. This is most likely to occurwith white in the case of a normal original image, which is the reasonwhy background pixels are set to white.

Then, the data size of the tile data that has gone through thecompression processing is calculated. This is the sum of thepattern-flag size, the first-color data size, and the second, third, andfourth-color data size. Since the pattern flag is always added, there isno guarantee that the data size will be reduced from the data size oforiginal image data. Thus, if the data size of tile data aftercompression exceeds that of original tile data, it is better to outputoriginal image data in terms of overall memory efficiency. Accordingly,the compressed data size and the original data size are compared (S1206)and if the compressed data size exceeds the original data size, thecompression flag of the header is set to 0 (S1207), and if not, the flagis set to 1 (S1209).

Then, in view of the above-described comparison result, either thecompressed tile data or the original tile data is packed together withthe header information of the tile into single data (S1208, S1210). Thedata structure of this packed data is shown in FIG. 14. Hereinafter, theunit of the above-described data including the header is referred to asa “packet”. Such a packet is generated by packing data with no spaceleft between the first-color storage section and the second, third, andfourth-color storage section after tile-by-tile compression processinghas been completed and the data size has been determined. Thereafter,the packet is output to the memory via the DMAC (S1211). Then, thecoordinates and size of this packet are listed to generate a packetmanagement table (S1212). An example of such a packet management tableis shown in FIG. 15. By repeating the above-described processing untilthe last tile (YES in S1213), the page-by-page compression processing ofthe raster image is completed.

Note that if data is written to the memory in tiles as described above,each packet will have different sizes and their starting addresses arelocated discretely as shown in FIG. 16. Thus, the starting address of apacket at any coordinates is searched using the packet management tableas shown in FIG. 15. Accordingly, if the writing address of the firstpacket is known, the starting address of any packet can be obtained byoffsetting the data size up to the coordinates described in the packetmanagement table. For example, in the case of reading the third packetshown in FIG. 16, the sum of the sizes of the first and second packetsis obtained from the packet management table and is offset from theaddress of the first packet in order to calculate the address of thethird packet. Then, data is read from there, which enables acquisitionof the third packet data.

As described above, any data can be accessed on a tile-by-tile basis,which enables partial processing of an image. For example, in the casewhere it is desired to extract and process an area in an image, it issufficient to acquire and process packet data corresponding to thatarea.

Moreover, since the header is assigned to each packet, decompressionprocessing is performed using information described in the header.First, if the compression flag indicates uncompressed data, dataexcluding the header is output, and if not, decompression processing isperformed. In the decompression processing, the pattern-flag storagelocation, the first-color-data storage location, and the second, third,and fourth-color-data storage location are obtained from the header, andthereafter, data is decompressed sequentially into tile image data inthe same manner as described in the above embodiments.

For example, the location of the pattern flag can be obtained byoffsetting since the header has a fixed length. As to the first colordata, it can be obtained by being offset from the location of thepattern flag since the size of the pattern flag is fixed at 32×32 bitswhen the tile size is 32×32 pixels. Lastly, the second, third, andfourth color data can be obtained by being offset from the location ofthe first color data by referring to the data size of the first colordata described in the header since the first color data has anindeterminate length.

According to the fifth embodiment, even in variable-length compressionprocessing that depends on image data and has a varying data size forcompressed data, it is possible to improve random accessibility tocompressed data and to extract and process part of an image on atile-by-tile basis.

Other Embodiments

Aspects of the present invention can also be realized by a computer of asystem or apparatus (or devices such as a CPU or MPU) that reads out andexecutes a program recorded on a memory device to perform the functionsof the above-described embodiments, and by a method, the steps of whichare performed by a computer of a system or apparatus by, for example,reading out and executing a program recorded on a memory device toperform the functions of the above-described embodiments. For thispurpose, the program is provided to the computer for example via anetwork or from a non-transitory recording medium of various typesserving as the memory device (e.g., computer-readable medium).

While the present invention has been described with reference toexemplary embodiments, it is to be understood that the invention is notlimited to the disclosed exemplary embodiments. The scope of thefollowing claims is to be accorded the broadest interpretation so as toencompass all such modifications and equivalent structures andfunctions.

This application claims the benefit of Japanese Patent Application No.2009-221444, filed Sep. 25, 2009, which is hereby incorporated byreference herein in its entirety.

1. An image processing apparatus for dividing image data into blockshaving a predetermined number of pixels and processing each of thedivided blocks in sequence, the apparatus comprising: identificationmeans for comparing color data of pixels in a block to be processed andidentifying a pattern flag that corresponds to a placement pattern ofthe color data included in the block; output means for outputting thepattern flag identified by the identification means and the color datafor the number of colors included in the block; and storage means for,assuming that color data output from the output means that correspondsto a pixel at a predefined position in the block is first color data,collectively storing the pattern flag, the first color data, and othercolor data that are output from the output means for each of the dividedblocks in respectively different memory areas.
 2. The apparatusaccording to claim 1, further comprising: color-reduction processingmeans for performing color-reduction processing on the block to beprocessed, wherein, after the color-reduction processing means performsthe color-reduction processing, the identification means compares thecolor data of pixels in the block to be processed and identifies apattern flag that corresponds to the placement pattern of the color dataincluded in the block.
 3. The apparatus according to claim 2, furthercomprising setting means for providing a user interface for setting athreshold value used by the color-reduction processing means indetermining whether or not to regard color data as the same color andperform color-reduction processing.
 4. The apparatus according to claim1, further comprising storage means for storing color data of a previousblock to be processed, wherein, when a difference between the color dataof the block to be processed and the color data stored in the storagemeans is small, the output means outputs a pattern flag indicatingrepetition of the previous block to be processed and does not output thecolor data of the block to be processed.
 5. The apparatus according toclaim 1, wherein, when attribute data indicating an attribute isassigned to each pixel in the blocks, the output means additionallyoutputs the attribute data.
 6. The apparatus according to claim 1,wherein an image in pages is divided into tiles that contain a largernumber of pixels than the blocks, the divided tiles are regarded as theimage data and each is divided into blocks having a predetermined numberof pixels, and each of the divided blocks is processed in sequence. 7.The apparatus according to claim 1, wherein the blocks are 2×2 pixelblocks.
 8. The apparatus according to claim 7, wherein the first colordata predefines a position in the 2×2 pixel blocks as the predefinedposition.
 9. The apparatus according to claim 1, wherein the color datais a pixel value.
 10. An image processing apparatus for dividing imagedata into 2×2 pixel blocks and processing each of the divided blocks insequence, the apparatus comprising: identification means for comparingcolor data of pixels in a block to be processed and identifying apattern flag that indicates a placement pattern of the color dataincluded in the block and the number of colors; extraction means forextracting, as first color data, color data that corresponds to a pixelat a predefined position in each of the 2×2 pixel blocks and, when thenumber of colors indicated by the identified pattern flag is determinedas any of two to four, further extracting second to fourth color databased on the placement pattern defined by the identified pattern flag;and storage means for collectively storing the pattern flag of eachblock identified by the identification means, the first color data ofeach block extracted by the extraction means, and the second to fourthcolor data of each block extracted by the extraction means inrespectively different memory areas.
 11. A processing method for animage processing apparatus for dividing image data into blocks having apredetermined number of pixels and processing each of the divided blocksin sequence, comprising: an identification step of comparing color dataof pixels in a block to be processed and identifying a pattern flag thatcorresponds to a placement pattern of the color data included in theblock; an output step of outputting the pattern flag identified in theidentification step and color data for the number of colors included inthe block; and a storage step of, assuming that color data output in theoutput step that corresponds to a pixel at a predefined position in theblock is first color data, collectively storing the pattern flag, thefirst color data, and other color data that are output in the outputstep for each of the divided blocks in respectively different memoryareas.
 12. A processing method for an image processing apparatus fordividing image data into 2×2 pixel blocks and processing each of thedivided blocks in sequence, comprising: an identification step ofcomparing color data of pixels in a block to be processed andidentifying a pattern flag that indicates a placement pattern of thecolor data included in the block and the number of colors; an extractionstep of extracting, as first color data, color data of a pixel at apredefined position in each of the 2×2 pixel blocks and, when the numberof colors indicated by the identified pattern flag is determined as anyof two to four, further extracting second to fourth color data based onthe placement pattern defined by the identified pattern flag; and astorage step of collectively storing the pattern flag of each blockidentified in the identification step, the first color data of eachblock extracted in the extraction step, and the second to fourth colordata of each block extracted in the extraction step in respectivelydifferent memory areas.
 13. A program stored in a non-transitorycomputer-readable recording medium and for causing a computer to performthe processing method for an image processing apparatus as described inclaim
 11. 14. A program stored in a non-transitory computer-readablerecording medium and for causing a computer to perform the processingmethod for an image processing apparatus as described in claim 12.